home *** CD-ROM | disk | FTP | other *** search
- A Fix for Handling Pointers to Functions in the Tree Chart Mode
-
- Functions invoked through a pointer (to that function) are difficult for
- diagrammers to handle. In the most general case, the actual function called
- could be dynamically determined (by the user, say) or could be referenced
- by a table offset. Short of compiling the program (or even running it if
- the user was asked to enter a function address!) there is no sure way to
- determine which functions are called by an arbitrary pointer reference.
-
- As a compromise, Clear for C now allows the programmer (who usually knows
- which functions are supposed to be called by a pointer reference) to
- provide for referencing the functions he/she intends to call.
-
- By including a comment of the form :
-
- /*# foo() boo() coo() */
-
- in the source code, the tree chart/function cross reference will treat these
- functions as being called by the function in which this comment appears.
- Be sure to include the # sign!
-
- A typical usage might be:
-
- /***************************************************************************/
- /* fnptrs.c */
- /* include str function declarations */
- #include <string.h>
-
- /* table of function pointers to be selected in program */
- int (*fn[2])()=
- {
- strcmp,
- stricmp
- };
-
- main()
- {
- int i;
-
- while(1)
- {
- printf("Enter 0 for Case Sensitive, 1 for Insensitive, -1 to Quit) ");
- scanf("%d",&i);
- if(i<0 || i>1)
- exit(0);
- printf("fn[%d](\"HI\",\"hi\") returns %d\n",i,fn[i]("HI","hi"));
- /*# strcmp() stricmp() */ /* references these actual functions in tree */
- /* remember to turn 'external functions ON' */
- }
- }
- /***************************************************************************/
-
-